Fix absolute API URL resolution for extensions#5940
Conversation
Extensions were receiving incomplete URLs when the API_URL config was relative (e.g., /graphql/). This caused issues in setups where extensions needed to communicate back to the Saleor backend. Changes: - Introduced getAbsoluteApiUrl() to consistently resolve full API URLs - Replaced direct getApiUrl() calls with getAbsoluteApiUrl() in extension-related code - Added test coverage for absolute URL resolution - Simplified URL construction logic by centralizing absolute URL resolution 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: c085e61 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
There was a problem hiding this comment.
Pull Request Overview
Adds a helper to reliably produce a fully qualified Saleor API URL when the configured API_URL may be relative, and updates all extension/app surfaces to use it. Also adds targeted tests and a changeset entry.
- Introduces getAbsoluteApiUrl() to normalize relative or absolute API_URL values.
- Replaces previous ad‑hoc URL construction usages with the centralized helper.
- Adds unit tests covering absolute vs relative API_URL resolution.
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/config.ts | Adds getAbsoluteApiUrl helper and related documentation comments. |
| src/config.test.ts | New tests validating absolute URL resolution behavior. |
| src/extensions/urls.ts | Switches to getAbsoluteApiUrl for extension iframe URL construction. |
| src/extensions/new-tab-actions.ts | Uses absolute API URL when posting data to new tab. |
| src/apps/urls.ts | Replaces inline URL resolution with helper. |
| src/apps/components/AppWidgets/AppWidgets.tsx | Passes absolute API URL in hidden form field to extensions. |
| .changeset/upset-apples-judge.md | Adds release note describing the fix (contains a typo). |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5940 +/- ##
=======================================
Coverage 40.06% 40.06%
=======================================
Files 2473 2473
Lines 40170 40171 +1
Branches 8821 8821
=======================================
+ Hits 16095 16096 +1
Misses 24048 24048
Partials 27 27 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Summary
getAbsoluteApiUrl()to consistently resolve full API URLsAPI_URLconfig is relative (e.g.,/graphql/)Problem
When the
API_URLconfiguration was set to a relative path (e.g.,/graphql/), extensions were receiving incomplete URLs. This caused issues in setups where extensions needed to communicate back to the Saleor backend, as they couldn't determine the full endpoint URL.Solution
Centralized absolute URL resolution in a new
getAbsoluteApiUrl()function that:window.location.originto create complete URLs🤖 Generated with Claude Code